import '../net/response/food/week_menu_list_data.dart';

/// weekDay : 1
/// timeSection : 1
/// categaryList : [{"categary":"熟食","goodsList":[{"id":21,"goodsName":"椒盐土豆","status":1},{"id":36,"goodsName":"八宝鸭","status":0},{"id":34,"goodsName":"大葱","status":0}]}]

class WeekPrintData {
  WeekPrintData({
    this.weekDay,
    this.timeSection,
    this.categaryList,
  });

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is WeekPrintData &&
          runtimeType == other.runtimeType &&
          weekDay == other.weekDay &&
          timeSection == other.timeSection;

  @override
  int get hashCode => weekDay.hashCode ^ timeSection.hashCode;

  WeekPrintData.fromJson(dynamic json) {
    weekDay = json['weekDay'];
    timeSection = json['timeSection'];
    if (json['categaryList'] != null) {
      categaryList = [];
      json['categaryList'].forEach((v) {
        categaryList?.add(CategaryList.fromJson(v));
      });
    }
  }

  String? date;
  int? weekDay;
  int? timeSection;
  String get time => timeSection==1?"早餐":timeSection==2?"午餐":"晚餐";
  List<CategaryList>? categaryList;

  WeekPrintData copyWith({
    int? weekDay,
    int? timeSection,
    List<CategaryList>? categaryList,
  }) =>
      WeekPrintData(
        weekDay: weekDay ?? this.weekDay,
        timeSection: timeSection ?? this.timeSection,
        categaryList: categaryList ?? this.categaryList,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['weekDay'] = weekDay;
    map['timeSection'] = timeSection;
    if (categaryList != null) {
      map['categaryList'] = categaryList?.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

/// categary : "熟食"
/// goodsList : [{"id":21,"goodsName":"椒盐土豆","status":1},{"id":36,"goodsName":"八宝鸭","status":0},{"id":34,"goodsName":"大葱","status":0}]

class CategaryList {
  CategaryList({
    this.categary,
    this.goodsList,
  });

  CategaryList.fromJson(dynamic json) {
    categary = json['categary'];
    if (json['goodsList'] != null) {
      goodsList = [];
      json['goodsList'].forEach((v) {
        goodsList?.add(GoodsList.fromJson(v));
      });
    }
  }

  String? categary;
  List<GoodsList>? goodsList;

  CategaryList copyWith({
    String? categary,
    List<GoodsList>? goodsList,
  }) =>
      CategaryList(
        categary: categary ?? this.categary,
        goodsList: goodsList ?? this.goodsList,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['categary'] = categary;
    if (goodsList != null) {
      map['goodsList'] = goodsList?.map((v) => v.toJson()).toList();
    }
    return map;
  }
}
